import { defineStore } from 'pinia';
import type {
	UserState
} from "./type";
import Cache from '../../../utils/Cache';
import { TOKEN_NAME } from '../../../config';

export default defineStore('user', {
	state: (): UserState => {
		return {
			token: Cache.getCache(TOKEN_NAME)
		}
	},
	actions: {
		logout() {
			Cache.clearCache(TOKEN_NAME);
			this.token = null;
		}
	}
})